from django.contrib import admin
from .models import TipOffs, User

admin.site.site_header = '图书馆选座后台'
admin.site.site_title = '中国人民公安大学图书馆选座后台'
admin.site.index_title = '中国人民公安大学图书馆选座后台'


# Register your models here.
@admin.register(TipOffs)
class TipOffsAdmin(admin.ModelAdmin):
    # listdisplay设置要显示在列表中的字段（id字段是Django模型的默认主键）
    list_display = ('create_time', 'seat_number', 'position', 'handle_time', 'get_handle_status')
    list_display_links = ('create_time', 'seat_number', 'position', 'handle_time', 'get_handle_status')
    list_filter = ('handle_status', 'create_time', 'position', 'handle_time',)
    search_fields = ('seat_number', 'note')
    exclude = ('seat', 'handle_time', 'handle_status')
    readonly_fields = ('seat_number', 'create_time', 'user', 'position', 'note')

    def has_add_permission(self, request):
        return False

    def has_delete_permission(self, request, obj=None):
        return False


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
    list_display = ('number', 'name', 'sex','phone','type')
    list_display_links = ('number', 'name', 'sex','phone','type')
    list_filter = ('sex', 'type')
    search_fields = ('number', 'name','phone')
